<template>
    <div>
        <a href="https://localhost:7155/api/Member/DaoChu">导出所有数据</a>
        <!-- 商铺名称:<input type="text" v-model="ts.name">
        房屋类型:
        <select v-model="ts.house">
            <option value="0">请选择</option>
            <option v-for="b in data" :value="b.houseId">{{ b.houseName }}</option>
        </select> -->
        <table class="table">
            <thead>
                <tr>
                    <td>编号</td>
                    <td>商铺名称</td>
                    <td>楼层</td>
                    <td>面积</td>
                    <td>商铺状态</td>
                    <td>是否删除</td>
                    <td>删除时间</td>
                    <td>房屋类型</td>
                    <td>联系电话</td>
                    <td>操作</td>
                </tr>
            </thead>
            <tbody>
                <tr v-for="a in date1">
                    <td>{{ a.memberiD }}</td>
                    <td>{{ a.memberName }}</td>
                    <td>{{ a.louceng }}</td>
                    <td>{{ a.mianji }}</td>
                    <td :style="a.state=='出租'?'color:green':'color:blue'">{{ a.state }}</td>
                    <td>{{ a.isDelete }}</td>
                    <td>{{ a.delDates }}</td>
                    <td>{{ a.houseName }}</td>
                    <td>{{ a.phone.substring(0,3) }}****{{ a.phone.substring(7,11) }}</td>
                    <td>
                        <input type="button" value="逻辑删除" @click="luo(a.memberiD)">
                        <input type="button" value="编辑" @click="upd(a.memberiD)">
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { ref,onMounted } from 'vue';
import { useRouter } from 'vue-router';
const routher = useRouter();
onMounted(()=>{
    getdate()
    show()
})
const upd=(val:any)=>{
    routher.push({path:"/Update",query:{id:val}})
}
const luo=(val:any)=>{
    if(!confirm("确认删除吗")){
        return
    }
    axios.delete("/api/Member/DelMember",{params:{id:val}}).then(res=>{
        if(res.data>0){
            alert("删除成功")
            show()
        }
        else{
            alert("删除失败")
        }
    })
}

const show=()=>{
    axios.get("https://localhost:7155/api/Member/Show",{params:date1.value}).then(res=>{
        date1.value=res.data
    })
}
const date1=ref([{
    "houseId": 0,
    "memberName": "",
    "memberiD": 0,
    "mianji": "",
    "state": "",
    "bian": "",
    "delDates": null,
    "isDelete": false,
    "louceng": "",
    "phone": "",
    "houseName": ""
}])

const getdate=()=>{
    axios.get("/api/House/GetHouseList").then(res=>{
        data.value=res.data
    })
}
const data=ref([{
    "houseId": 0,
    "houseName": ""
}])
</script>

<style scoped>

</style>